package com.example.webapp.service.impl;

import com.example.webapp.bean.QuestionBank;

import com.example.webapp.dao.QuestionBankDao;
import com.example.webapp.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private final QuestionBankDao questionDao;

    public QuestionServiceImpl(QuestionBankDao questionDao) {
        this.questionDao = questionDao;
    }

    @Override
    public void createQuestion(QuestionBank q) {
        questionDao.save(q);
    }

    @Override
    public void updateQuestion(QuestionBank q) {
        questionDao.save(q);
    }

    @Override
    public void deleteQuestion(Integer id) {
        questionDao.deleteById(id);
    }

    @Override
    public QuestionBank getQuestionById(Integer id) {
        return questionDao.findById(id).orElse(null);
    }

}